/**
* All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
*
* SdProjectRiskService
* SD项目风险
*
* 修改纪录
* 2021-12-17 版本：1.0 jiangtao 创建。
* @version 版本：1.0
* @author 作者：jiangtao
* 创建日期：2021-12-17
*/
package com.topscomm.gpm.service.impl;

import com.topscomm.tap.TapEntity;
import com.topscomm.tap.common.DatacodeCache;
import com.topscomm.tap.common.SessionUserBean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.gpm.service.IGpmProjectRiskService;
import com.topscomm.gpm.service.impl.auto.GpmProjectRiskServiceAuto;
import com.topscomm.basic.BasicEntity;
import com.topscomm.gpm.pojo.GpmProjectRiskEntity;

import java.util.Map;

@Service(value = "gpmProjectRiskService")
@Scope(value = "singleton")
public class GpmProjectRiskService extends GpmProjectRiskServiceAuto implements IGpmProjectRiskService {
	/**
	 * @author: jiangtao
	 * @date: 2021-12-17
	 * @param entity
	 * @throws
	 * @description:单号生成
	 * @modify:
	 */
	@Override
	protected void beforeInsert(BasicEntity entity){
		super.beforeInsert(entity);
		//  赋值Id和单号和项目编号
		GenerateIDAndCode(entity,"PR",(GpmProjectRiskEntity.FieldRiskcode));
	}

	/**
	 * @description: 赋值编号 docno改为提交时创建
	 * @author xinfushuo
	 * @param
	 * @throws
	 * @return
	 * @date 2021/9/10
	 * @modify
	 */
	@Override
	protected void beforeSubmit(TapEntity entity, SessionUserBean sessionUserBean){
		//  赋值单号和项目编号
		super.beforeSubmit(entity,sessionUserBean);
		GenerateIDAndCode(entity,"PR",(GpmProjectRiskEntity.FieldRiskcode));
	}

	@Override
	public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
		super.setDispFields(mapRow, datacodeCache);
		String temp;
		//流程名字显示
		if (mapRow.get("flowid") != null) {
			temp = mapRow.get("flowid").toString();
			mapRow.put("dispflowid", datacodeCache.getValueDynamic("ApprovalFlow_GpmProjectRisk", temp, "id", "name"));
		}
		//项目风险可能性显示
		if (mapRow.get("riskprobability") != null) {
			temp = mapRow.get("riskprobability").toString();
			mapRow.put("dispriskprobability", datacodeCache.getValueDynamic("GpmProjectRiskProbability", temp, "code", "name"));
		}
		//项目影响等级显示
		if (mapRow.get("riskinfluencelevel") != null) {
			temp = mapRow.get("riskinfluencelevel").toString();
			mapRow.put("dispriskinfluencelevel", datacodeCache.getValueDynamic("GpmProjectRiskInfluenceLevel", temp, "code", "name"));
		}

		//项目风险等级显示
		if (mapRow.get("risklevel") != null) {
			temp = mapRow.get("risklevel").toString();
			mapRow.put("disprisklevel", datacodeCache.getValueDynamic("GpmProjectRiskLevel", temp, "code", "name"));
		}
		//项目风险性质显示
		if (mapRow.get("riskproperty") != null) {
			temp = mapRow.get("riskproperty").toString();
			mapRow.put("dispriskproperty", datacodeCache.getValueDynamic("GpmProjectRiskProperty", temp, "code", "name"));
		}
		//项目风险趋势显示
		if (mapRow.get("risktrend") != null) {
			temp = mapRow.get("risktrend").toString();
			mapRow.put("disprisktrend", datacodeCache.getValueDynamic("GpmProjectRiskTrend", temp, "code", "name"));
		}
		//配置项目等级显示值
		if (mapRow.get("projectlevel") != null) {
			temp = mapRow.get("projectlevel").toString();
			mapRow.put("dispprojectlevel", datacodeCache.getValueDynamic("GpmProjectLevel", temp, "code", "name"));
		}
		//配置风险状态显示值
		if (mapRow.get("riskstatus") != null) {
			temp = mapRow.get("riskstatus").toString();
			if (temp.equals("2")) {
				mapRow.put("dispriskstatus", "关闭");
			} else {
				mapRow.put("dispriskstatus", datacodeCache.getValueDynamic("GpmProjectRiskStatus", temp, "code", "name"));
			}
		}
		// 配置里程碑/任务字段显示
		if (mapRow.get("relateobject") != null) {
			temp = mapRow.get("relateobject").toString();
			mapRow.put("disprelateobject", datacodeCache.getValueDynamic("GpmMilepostOrTask", temp, "code", "name"));
		}
	}
}
